package com.dragon.repository.domain.dto;

import com.dragon.repository.entity.ContractArticle;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.dragon.common.util.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ContractArticleDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "条款标题")
    private String articleTitle;

    @ApiModelProperty(value = "条款内容")
    private String articleText;

    @ApiModelProperty(value = "条款创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "是否默认： 0否 1是")
    private Integer isDefault;


    public ContractArticleDTO() {}

    public ContractArticleDTO(ContractArticle entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static ContractArticleDTO convert(ContractArticle entity) {
        return new ContractArticleDTO(entity);
    }

    public static List<ContractArticleDTO> convertList(List<ContractArticle> list) {
        List<ContractArticleDTO> resultList = new ArrayList<>();
        for (ContractArticle entity : list) {
            resultList.add(new ContractArticleDTO(entity));
        }
        return resultList;
    }}
